DIC Results

In [13]:
%matplotlib inline
from IPython.display import HTML
from base64 import b64encode
from IPython.display import Image
%matplotlib inline

Histogram Plot

Equation used to extract Eyy strain from the vector data

Strain is calculated using the central difference scheme. For Eyy the vector displacement from the top and bottom is divided by 2x grid spacing

\[E_{yy}=\frac{(V_{y}*(n+1)-Vy(n-1))}{2.g}\] where Vy is the pixel displacement in the y axis and n is the y coordinate of the displacement pixel g is the grid spacing and is equal to:

\[g=\frac{interrogationwindowsize}{(100/(100-overlap))}\]

In [14]:
def vector_data(file_name,window_size,mm_per_pixel):#mm_per_pixel calculated using Image_J
    plot_data=[]
    Vy_list=loadtxt(file_name)[:,3]
    n_list=loadtxt(file_name)[:,1]
    for Vy,n in zip(Vy_list,n_list):
        g=(window_size*mm_per_pixel)/(100/75)
        Eyy_strain=((Vy*(n+1))-(Vy*(n-1)))/(2*g)
        plot_data.append(Eyy_strain)
    hist(plot_data);

Plotting Strain Data straight from DaVis

In [15]:
def data(file_name):
    plot_data=loadtxt(file_name)[:,100:]
    hist(plot_data.flatten());
    

Displaying TIFF File inline (It is converted to PNG first)

In [16]:
from io import BytesIO
from IPython.core import display
from PIL import Image

def display_pil_image(im):
    '''
    Based on the display hookery:
    http://nbviewer.ipython.org/gist/deeplook/5162445
    '''
    b = BytesIO()
    im.save(b, format='png')
    data = b.getvalue()
    ip_img = display.Image(data=data, format='png', embed=True)
    return ip_img._repr_png_()

png_formatter = get_ipython().display_formatter.formatters['image/png']
dpi = png_formatter.for_type(Image.Image, display_pil_image)

Python conversion of vector data to strain data

This uses the equation above. The error seems much larger than that when the histogram is plotted using the Eyy strain map from DaVis straight away

In [17]:
vector_data('C:\\Users\\Luqmaan\\Anaconda\\eyy_strains\\T9E_Tensile_Vec.txt',32,0.003676)

Strain Data Calculated from DaVis

In [18]:
data('C:\\Users\\Luqmaan\\Anaconda\\eyy_strains\\T9E_Tensile_1.txt')
In [9]:
im = Image.open('C:\Export\Tensile_9_shift\B00001.tif')
In [10]:
im
Out[10]:

Tensile 3 Strain Video

In [11]:
video = open("C:\Export\Tensile_3_eyy_1.mp4", "rb").read()
video_encoded = b64encode(video)
video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
HTML(data=video_tag)
Out[11]:

Tensile 3 Shift Correction video

In [12]:
video = open("C:\Export\Tensile_3_shift_01.3gp", "rb").read()
video_encoded = b64encode(video)
video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
HTML(data=video_tag)
Out[12]:
In []: